﻿using IntelligentAgriculture.Contracts.Dto.Output.CustomerinformationSOutput;
using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Contracts.Interface.EarTagService;
using IntelligentAgriculture.Contracts.Interface.ICustomerinformationService;
using IntelligentAgriculture.Services.EarTageService;
using IntelligentAgriculture.WebAPI.Application.Command.CustomerinformationCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.CustomerinformationShowCommandHandler
{
    public class CustomerinformationShowCommandHandler : IRequestHandler<CustomerinformationShowCommand, Results<PagesOutput<CustomerinformationShowOutput>>>
    {
        private readonly ICustomerinformationService _ICustomerinformationService;
        public CustomerinformationShowCommandHandler(ICustomerinformationService iCustomerinformationService)
        {
            _ICustomerinformationService = iCustomerinformationService;
        }
        /// <summary>
        /// 显示,查询,分页
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<PagesOutput<CustomerinformationShowOutput>>> Handle(CustomerinformationShowCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _ICustomerinformationService.GetShow(request.Eitag);
                var results = Results<PagesOutput<CustomerinformationShowOutput>>.DataResult(list);
                return results;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
